import java.util.Scanner;

public class Calculation {
    public static void main(String[] args) {

        System.out.println("please choose your caculation");
        Scanner scanner=new Scanner(System.in);

        if(scanner.hasNextLine()){
            String method= scanner.nextLine();
            System.out.println("please 定义一个值a");
            Scanner scanner1=new Scanner(System.in);

            //为什么要重新实例化一个Scanner对象？
            if(scanner.hasNextLine()) {
                int a = scanner1.nextInt();
            }


            System.out.println("please 定义一个值b");
            Scanner scanner2=new Scanner(System.in);
            if(scanner.hasNextLine()) {
                int b = scanner2.nextInt();}
            if(method.equals("add")){
                int result=Calculation.add(scanner1.nextInt(), scanner2.nextInt());

                //a, b没有用到，这里的两个scanner重新输入了。
                //并且a和b的作用域不一样，a在这个if里面是没有办法通用的。
                System.out.println(result);
            }
        }

    }
    public static int add(int a,int b){
        return a+b;
    }

    public static int substract(int a,int b){
        return a-b;
    }

    public static int multiply(int a,int b){
        return a*b;
    }

    public static double divide(double a,double b){
        return a/b;
    }

}

